define([],function(){
	var URLS = {
		getChapterInfo : {
            url: '/chapter/getChapterInfo',
            method: 'GET',
            type:'json',
        },
        getNodeChaptersInfo : {
            url: '/chapter/getNodeChaptersInfo',
            method: 'GET',
            type:'json',
        },
        listChaptersByNodeId : {
            url: '/chapter/listChaptersByNodeId',
            method: 'GET',
            type:'json',
        },
        listChaptersByStoryId : {
            url: '/chapter/listChaptersByStoryId',
            method: 'GET',
            type:'json',
        },
        getStoryChapter: {
            url: '/chapter/getStoryChapter',
            method: 'GET',
            type:'json',
        },
        postChapter : {
            url: '/chapter/commit/postChapter',
            method: 'POST',
            type:'json',
        },
        listChapter : {
            url: '/chapter/listChapter',
            method: 'GET',
            type:'json',
        },
        getStoryInfo: {
            url: '/story/getStoryInfo',
            method: 'GET',
            type:'json',
        },
        postStory : {
            url: '/story/commit/postStory',
            method: 'POST',
            type:'json',
        },
        listNode : {
            url: '/story/listNode',
            method: 'GET',
            type:'json',
        },
        listStory : {
            url: '/story/listStory',
            method: 'GET',
            type:'json',
        }
	};
	return function(name,data, fn_success,fn_fail){
		if(URLS[name]){
			$.ajax({
            type: URLS[name].method,
            dataType: URLS[name].type,
            url:  URLS[name].url,
            data: data,
            success: function (result) {
                fn_success && fn_success.call(this,result);
            },
            error: function(err) {
                console.log("ajax faild");
                fn_fail && fn_fail.call(this,result);
            }
        });
		}
	}
});